//
// Created by 下次一定 on 2021/9/26.
//

#include <iostream>
#include <algorithm>
using namespace std;

const int N = 110;
int triangle[N][N];
int n;
int dp[N][N];
int main(){
    cin >> n;
    for (int i = 1; i <= n; i ++ ){
        for (int j = 1; j <= i ;j ++){
            cin >> triangle[i][j];
        }
    }

    for (int i = 0; i <= n+1 ;i++)
        for(int j = 0; j <= n+1; j++)
            dp[i][j] = -101010;
    dp[1][1] = triangle[1][1];

    for (int i = 2; i <= n; i ++)
        for (int j = 1; j <= i; j ++)
            dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+triangle[i][j];
    int res = -101010;
    for(int i = 1; i <= n; i ++ )res = max(res,dp[n-1][i]);
    cout << res;
}
